<?php
class add extends db 
{
    public function index()
    {
        $this->usershell();
        if($_REQUEST['sub'])
        {
            if($this->check_user($_REQUEST['per_ID']) === TRUE)
            {
                $date = $_REQUEST['Date_Year'].'-'.$_REQUEST['Date_Month'].'-'.$_REQUEST['Date_Day'];
                $result = $this->update_userinfo($_REQUEST['unit'],
                                                    $_REQUEST['name'],
                                                    $_REQUEST['sex'],
                                                    $date,
                                                    $_REQUEST['age'],
                                                    $_REQUEST['phone'],
                                                    $_REQUEST['per_ID']);
    //            print_r($result);exit;
                switch ($result) 
                {
                    case TRUE:
                        echo "<script>alert('添加成功！')</script>";
                        break;
                    case FALSE:
                        echo "<script>alert('添加失败！')</script>";
                        break;
                }
            }
            else
                echo "<script>alert('此用户身份证重复！')</script>";
        }
 
        $options = $this->get_unit();
        foreach ($options as $key => $value)    //重新组合数组
        {
            $a[$value[0]] = $value[1];
        }
        
        $this->assign("options", $a);

        $this->assign("sex", array('女', '男'));

        $this->display("add.tpl");
    }
}
?>
